package com.woniu.ly.manageassembly.controller;

import com.woniu.ly.facade.HotelFeignClient;
import com.woniu.ly.manageassembly.service.HotelService;
import com.woniu.ly.model.common.Result;
import com.woniu.ly.model.model.Hotel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Slf4j
public class HotelController implements HotelFeignClient {
    @Autowired
    private HotelService hotelService;
    /*
    * 酒店账号(新增酒店)
    * */
    public Result addHotel(String hotelName
            , String hotelTel
            , String hotelAddress
            , double hotelLongitude
            , double hotelLatitude){
        Hotel hotel = new Hotel();
        hotel.setHotelName(hotelName);
        hotel.setHotelTel(hotelTel);
        hotel.setHotelAddress(hotelAddress);
        hotel.setHotelLongitude(hotelLongitude);
        hotel.setHotelLatitude(hotelLatitude);
        hotel.setHotelStatus("待审核");
        hotel.setHotelComplain(0);
        log.info("酒店信息为：{}",hotel);
        int hotelId = hotelService.addHotel(hotel);
        log.info("酒店id为：{}",hotelId);
        return Result.success("新增成功");
    }
    /*
     * 酒店账号(修改酒店)
     * */
    public Result changeHotel(int hotelId
            , String hotelName
            , String hotelTel
            , String hotelAddress
            , double hotelLongitude
            , double hotelLatitude){
        Hotel hotel = new Hotel();
        hotel.setHotelName(hotelName);
        hotel.setHotelId(hotelId);
        hotel.setHotelTel(hotelTel);
        hotel.setHotelAddress(hotelAddress);
        hotel.setHotelLongitude(hotelLongitude);
        hotel.setHotelLatitude(hotelLatitude);
        hotel.setHotelStatus("待审核");
        hotel.setHotelComplain(0);
        log.info("酒店信息为：{}",hotel);
        hotelService.changeHotel(hotel);
        log.info("酒店id为：{}",hotelId);
        return Result.success("修改成功");
    }
    /*
     * 酒店账号(根据酒店Id查找)
     */
    public Result getHotel(int hotelId){
        log.info("酒店Id为：{}",hotelId);
        Hotel hotel = hotelService.getHotel(hotelId);
        return Result.success(hotel);
    }
}
